package com.ctshk.app.localfun.controller;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.TokenUser;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.localfun.dto.LocalFunProductDetailsResDTO;
import com.ctshk.rpc.localfun.dto.es.*;
import com.ctshk.rpc.localfun.req.*;
import com.ctshk.rpc.localfun.req.cache.LocalFunOrderReq;
import com.ctshk.rpc.localfun.service.ILocalFunAppProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Description 当地玩乐-产品中心
 * @Author wansi <gaylen15527491065@yeah.net>
 * @Date 2021/3/24
 */
@RestController
@RequestMapping("/local-fun-product")
@Api(value = "当地玩乐-C端前端控制器",tags = "当地玩乐-PC")
public class LocalFunProductController extends BaseController {

    @DubboReference
    private ILocalFunAppProductService iLocalFunAppProductService;

    @ApiOperation(value="", notes="當地玩樂-首页接口",tags = "当地玩乐-PC-首页接口")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.QUERY, operTitle = "当地玩乐-产品展示列表", operDesc = "當地玩樂-产品展示列表")
    @PostMapping("/query-product-list")
    public Result<LocalFunHomeDto> queryProductList(@RequestBody @Valid PCLocalFunQueryReq req){
       return iLocalFunAppProductService.queryProductList(req);
    }


    @ApiOperation(value="", notes="當地玩樂-搜索类别",tags = "当地玩乐-PC-搜索类别")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.QUERY, operTitle = "当地玩乐-搜索类别", operDesc = "當地玩樂-搜索类别")
    @PostMapping("/query-kind-product")
    public Result<LocalFunSearchDTO> queryKindProduct(@RequestBody @Valid PCLocalFunQueryReq req){
        return iLocalFunAppProductService.queryKindProduct(req);
    }

    @ApiOperation(value="", notes="當地玩樂-获取入口列表接口",tags = "当地玩乐-PC-获取入口列表接口")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.QUERY, operTitle = "当地玩乐-获取入口列表接口", operDesc = "當地玩樂-获取入口列表接口")
    @PostMapping("/get-theme-list")
    public Result<List<LocalFunHomeTitleDTo>> getThemeList(@RequestBody @Valid PCLocalFunQueryReq req){
        return iLocalFunAppProductService.getHomeTitleList(req);
    }


    @ApiOperation(value="", notes="當地玩樂-产品详情",tags = "当地玩乐-PC-产品详情")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.QUERY, operTitle = "当地玩乐-产品详情", operDesc = "當地玩樂-产品详情")
    @PostMapping("/query-product-details")
    public Result<LocalFunProductDetailsResDTO> queryHomeProductList(@RequestBody LocalFunProductDetailsQueryReq req){
        req.setUserId(getCurrentUserAllowNotLogInUserId());
        return iLocalFunAppProductService.queryProductDetails(req);
    }

    @ApiOperation(value="", notes="當地玩樂-支付详情列表",tags = "当地玩乐-PC-支付详情列表")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.UPDATE, operTitle = "当地玩乐-支付详情列表", operDesc = "當地玩樂-支付详情列表")
    @PostMapping("/paydetails")
    public Result payDetails(@RequestParam(required = false) String queryNumber ){
        TokenUser currentUser = getCurrentUser();
        return Result.success(iLocalFunAppProductService.payDetails(queryNumber,currentUser));
    }

    @ApiOperation(value="", notes="當地玩樂-获取核对订单页面信息",tags = "当地玩乐-PC-获取核对订单页面信息")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.UPDATE, operTitle = "当地玩乐-支付详情列表", operDesc = "當地玩樂-支付详情列表")
    @PostMapping("/get-order")
    public Result<LocalFunReservationGetOrderDTO> getOrderInfo(@RequestBody LocalFunOrderReq localFunOrderReq){
        return iLocalFunAppProductService.getOrderInfo(localFunOrderReq,getCurrentUserAllowNotLogInUserId());
    }

    @ApiOperation(value="", notes="當地玩樂-获取热门推荐列表",tags = "当地玩乐-PC-获取热门推荐列表")
    @OperationLogAnnotation(operModul = OperationLogModel.LOCALFUN, operType = OperationLogType.QUERY, operTitle = "当地玩乐-产品展示列表", operDesc = "當地玩樂-产品展示列表")
    @PostMapping("/get-hot-recommends")
    public Result<List<HotLocalFunDto>> getHotRecommends(@RequestBody PCLocalFunQueryReq req){
        return iLocalFunAppProductService.getHotRecommends(req);
    }
}
